<?php

namespace plugin\admin\app\model;

use app\payment\PayFactory;
use plugin\admin\app\model\Base;

/**
 * @property integer $id (主键)
 * @property string $order_no 订单编号
 * @property integer $refund_type 1退款,2退款退货
 * @property string $refund_reason 退款原因
 * @property string $refund_amount 退款金额
 * @property string $refund_desc 退款说明
 * @property string $refund_images 退款凭证
 * @property integer $status 退款状态
 * @property string $created_time 创建时间
 */
class OrderRefund extends Base
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_order_refunds';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';
    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    const UNPROCESS = 1;

    const AGREE = 2;

    const REJECT = -1;

    const CANCEL = 3;

    const BACK = 4;

    public static function getStatusText($status)
    {
        switch ($status) {
            case self::AGREE:
                return '已同意';
            case self::REJECT:
                return '已拒绝';
            case self::CANCEL:
                return '已取消';
            case self::UNPROCESS:
                return '未处理';
            case self::BACK:
                return '已退款';

        }
    }

    public static function getRefundTypeText($order)
    {
        if (!$order['refund_type']) {
            return '';
        }

        switch ($order['refund_type']) {
            case 1:
                return '仅退款';
            case 2:
                return '退款退货';
        }
    }

    public static function getRefundWalletText($order)
    {
        if (!$order['pay_way']) {
            return '';
        }

        switch ($order['pay_way']) {
            case PayFactory::BALANCE:
                return '余额钱包';
            case PayFactory::WECHAT:
                return '微信钱包';
            case PayFactory::ALIPAY:
                return '支付宝钱包';
        }
    }
}
